package com.asiainfo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;


/** 
 * springboot启动时会自动注入数据源，从而报错：
	Cannot determine embedded database driver class for database type NONE
	If you want an embedded database please put a supported one on the classpath. 
	If you have database settings to be loaded from a particular profile 
	you may need to active it (no profiles are currently active).
 * 我尝试了exclude，但并不能解决。
 */
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class })
/**
 * 此处也可以用@EnableEurekaClient替代@EnableDiscoveryClient。
 * EnableDiscoveryClient是抽象，支持多种服务发现组件，EnableEurekaClient是eureka特定的实现。
 * EnableEurekaClient为激活eureka client，通过eureka检索注册服务实例。
 * 配置该注解后，必须配置eureka的服务地址等信息，否则报错：
 * com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server
 */
@EnableDiscoveryClient
//@EnableEurekaClient

//java.lang.ClassNotFoundException: com.netflix.hystrix.contrib.javanica.aop.aspectj.HystrixCommandAspect

//@EnableCircuitBreaker
//@EnableFeignClients
public class ClientMicroserviceApplication {

	public static void main(String[] args) throws Exception {
		SpringApplication.run(ClientMicroserviceApplication.class, args);
	}
	
	@LoadBalanced
	@Bean
	RestTemplate restTemplate() {
		return new RestTemplate();
	}
	

}
